package com.guigu.eduservice.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * <p>
 * 订单表（存储买卖双方的交易订单信息）
 * </p>
 *
 * @author Xiaosong
 * @since 2025-10-01
 */
@Data
@TableName("`order`")
public class Order implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 订单唯一标识
     */
    @TableId(value = "order_id", type = IdType.AUTO)
    private Long orderId;

    /**
     * 关联用户表user_id（买家）
     */
    private Long buyerId;

    /**
     * 关联用户表user_id（卖家）
     */
    private Long sellerId;

    /**
     * 关联设备表equipment_id（唯一，一个设备同一时间仅一个有效订单）
     */
    private Long equipmentId;

    /**
     * 订单总金额（单位：元，设备成交价格）
     */
    private BigDecimal orderAmount;

    /**
     * 定金金额（订单总金额的30%，用于锁定设备）
     */
    private BigDecimal depositAmount;

    /**
     * 尾款金额（订单总金额-定金金额）
     */
    private BigDecimal balanceAmount;

    /**
     * 定金支付时间（买家支付定金的时间）
     */
    private LocalDateTime depositPayTime;

    /**
     * 尾款支付时间（买家支付尾款的时间）
     */
    private LocalDateTime balancePayTime;

    /**
     * 订单状态（0-待支付定金，1-已支付定金，2-待支付尾款，3-已支付尾款，4-已发货，5-已收货，6-已完成，7-已取消）
     */
    private Integer orderStatus;

    /**
     * 支付方式（微信支付、支付宝支付、银行卡支付等）
     */
    private String paymentMethod;

    /**
     * 物流公司（订单状态=4时必填，如顺丰、德邦）
     */
    private String logisticsCompany;

    /**
     * 物流单号（订单状态=4时必填，用于查询物流进度）
     */
    private String logisticsNo;

    /**
     * 确认收货时间（订单状态=5时必填，买家点击确认收货的时间）
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private LocalDateTime receiptTime;

    /**
     * 评价时间（订单状态=6时必填，买家提交评价的时间）
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")

    private LocalDateTime evaluationTime;

    /**
     * 记录创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime=LocalDateTime.now();

    /**
     * 记录更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime=LocalDateTime.now();
    /**
     *  设备品牌（如三菱、三菱重工、三菱重工（中国））
     */
     @TableField(exist = false)
    private String brand;

    /**
     * 设备型号（如SY215C、LW500FV）
     */
    @TableField(exist = false)
    private String model;

    /**
     * 设备生产年份（如2020）
     */
    @TableField(exist = false)
    private Integer year;

    /**
     * 设备使用小时数（反映设备磨损程度）
     */
    @TableField(exist = false)
    private Integer hour;

    /**
     * 设备价格（单位：元，精确到分）
     */
    @TableField(exist = false)
    private BigDecimal price;

    /**
     * 垂直高度（单位：米，如起重机的最大起升高度）
     */
    @TableField(exist = false)
    private BigDecimal verticalHeight;

    /**
     * 底盘桥数（如2桥、3桥，用于描述车辆底盘结构）
     */
    @TableField(exist = false)
    private Integer chassisAxle;

    /**
     * 支腿形式（如H型、X型，用于起重机等设备）
     */
    @TableField(exist = false)
    private String outriggerType;

    /**
     * 排放标准（如国三、国四，反映环保合规性）
     */
    @TableField(exist = false)
    private String emissionStandard;

    /**
     * 设备所在地（省/市/区，如广东省深圳市南山区）
     */
    @TableField(exist = false)
    private String location;

    /**
     * 联系人（设备咨询的对接人）
     */
    @TableField(exist = false)
    private String contactName;

    /**
     * 联系电话（设备咨询的联系方式）
     */
    @TableField(exist = false)
    private String contactPhone;

    /**
     * 设备描述（富文本格式，含设备使用情况、维护记录等）
     */
    @TableField(exist = false)
    private String description;

    @TableField(exist = false)
    private String imageUrl;
    @TableField(exist = false)
    private String typeName;
    @TableField(exist = false)
    private String typeDesc;


    public Long getOrderId() {
        return orderId;
    }

    public void setOrderId(Long orderId) {
        this.orderId = orderId;
    }

    public Long getBuyerId() {
        return buyerId;
    }

    public void setBuyerId(Long buyerId) {
        this.buyerId = buyerId;
    }

    public Long getSellerId() {
        return sellerId;
    }

    public void setSellerId(Long sellerId) {
        this.sellerId = sellerId;
    }

    public Long getEquipmentId() {
        return equipmentId;
    }

    public void setEquipmentId(Long equipmentId) {
        this.equipmentId = equipmentId;
    }

    public BigDecimal getOrderAmount() {
        return orderAmount;
    }

    public void setOrderAmount(BigDecimal orderAmount) {
        this.orderAmount = orderAmount;
    }

    public BigDecimal getDepositAmount() {
        return depositAmount;
    }

    public void setDepositAmount(BigDecimal depositAmount) {
        this.depositAmount = depositAmount;
    }

    public BigDecimal getBalanceAmount() {
        return balanceAmount;
    }

    public void setBalanceAmount(BigDecimal balanceAmount) {
        this.balanceAmount = balanceAmount;
    }

    public LocalDateTime getDepositPayTime() {
        return depositPayTime;
    }

    public void setDepositPayTime(LocalDateTime depositPayTime) {
        this.depositPayTime = depositPayTime;
    }

    public LocalDateTime getBalancePayTime() {
        return balancePayTime;
    }

    public void setBalancePayTime(LocalDateTime balancePayTime) {
        this.balancePayTime = balancePayTime;
    }

    public Integer getOrderStatus() {
        return orderStatus;
    }

    public void setOrderStatus(Integer orderStatus) {
        this.orderStatus = orderStatus;
    }

    public String getPaymentMethod() {
        return paymentMethod;
    }

    public void setPaymentMethod(String paymentMethod) {
        this.paymentMethod = paymentMethod;
    }

    public String getLogisticsCompany() {
        return logisticsCompany;
    }

    public void setLogisticsCompany(String logisticsCompany) {
        this.logisticsCompany = logisticsCompany;
    }

    public String getLogisticsNo() {
        return logisticsNo;
    }

    public void setLogisticsNo(String logisticsNo) {
        this.logisticsNo = logisticsNo;
    }

    public LocalDateTime getReceiptTime() {
        return receiptTime;
    }

    public void setReceiptTime(LocalDateTime receiptTime) {
        this.receiptTime = receiptTime;
    }

    public LocalDateTime getEvaluationTime() {
        return evaluationTime;
    }

    public void setEvaluationTime(LocalDateTime evaluationTime) {
        this.evaluationTime = evaluationTime;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    @Override
    public String toString() {
        return "Order{" +
            "orderId = " + orderId +
            ", buyerId = " + buyerId +
            ", sellerId = " + sellerId +
            ", equipmentId = " + equipmentId +
            ", orderAmount = " + orderAmount +
            ", depositAmount = " + depositAmount +
            ", balanceAmount = " + balanceAmount +
            ", depositPayTime = " + depositPayTime +
            ", balancePayTime = " + balancePayTime +
            ", orderStatus = " + orderStatus +
            ", paymentMethod = " + paymentMethod +
            ", logisticsCompany = " + logisticsCompany +
            ", logisticsNo = " + logisticsNo +
            ", receiptTime = " + receiptTime +
            ", evaluationTime = " + evaluationTime +
            ", createTime = " + createTime +
            ", updateTime = " + updateTime +
        "}";
    }
}
